package
{

	import flash.display.MovieClip;

public dynamic class CustomCursor extends MovieClip
{
/*
    var _parent;
    var _rotation;
    var _x;
    var _xscale;
    var _y;
	*/
    var cPoses;
    var frameState;
	/*
    var gotoAndStop;
    var onEnterFrame;
	*/

    function CustomCursor()
    {
        super();
        this.cPoses = [];
        this.cPoses.push(new Point(this.parent._xmouse, this.parent._ymouse));
        this.changeState("def");
        Mouse.hide();
    }

    function defEF()
    {
        this.x = this.parent._xmouse;
        this.y = this.parent._ymouse;
        this.savePos();
    }

    function cricketEF()
    {
        this.x = this.parent._xmouse;
        this.y = this.parent._ymouse;
        var __reg4 = MyMath.getAngle(this.cPoses[0].x, this.cPoses[0].y, this.parent._xmouse, this.parent._ymouse);
        if (__reg4 > 90 && __reg4 < 270) 
        {
            this.scaleX = -100;
            if (__reg4 < 150) 
            {
                __reg4 = 150;
            }
            else if (__reg4 > 210) 
            {
                __reg4 = 210;
            }
            __reg4 = __reg4 - 180;
        }
        else 
        {
            this.scaleX = 100;
            if (__reg4 > 30 && __reg4 < 270) 
            {
                __reg4 = 30;
            }
            else if (__reg4 < 330 && __reg4 > 90) 
            {
                __reg4 = 330;
            }
        }
        this.rotation = __reg4;
        var __reg5 = this.parent.theGame.checkFlyingEnemyHit(this);
        for (var __reg6 in __reg5) 
        {
            var __reg2 = __reg5[__reg6];
            var __reg3 = MyMath.getDistance(this.cPoses[0].x, this.cPoses[0].y, this.parent._xmouse, this.parent._ymouse) / 2;
            if (__reg3 > 5) 
            {
                trace("d:" + __reg3);
                this.parent.theGame.removeFlyingEnemy(__reg2);
                this.parent.theGame.hitSound();
                __reg2.gotoAndStop("beenHit");
                if (this.scaleX == -100) 
                {
                    __reg4 = __reg4 + 180;
                }
                __reg2.xv = __reg3 * Math.cos(__reg4 * MyMath.PiRads);
                __reg2.yv = __reg3 * Math.sin(__reg4 * MyMath.PiRads);
                __reg2.hitByBat = true;
                this.parent.theGame.addStarBurst(__reg2.x, __reg2.y);
                SoundManager.startSound("hit" + Math.floor(Math.random() * 3));
            }
        }
        this.savePos();
    }

    function changeState(st)
    {
        if (this.frameState != st) 
        {
            this.frameState = st;
            if (st == "cricketBat") 
            {
                this.onEnterFrame = this.cricketEF;
                return this.gotoAndStop(st);
            }
            this.rotation = 0;
            this.scaleX = 100;
            this.onEnterFrame = this.defEF;
        }
    }

    function savePos()
    {
        this.cPoses.shift();
        this.cPoses.push(new Point(this.x, this.y));
    }

}


}